public class PrintableAccountStrategy {


    //String accountStrategyId {get;set;}
    public Mi_Objeto__c accStr {get;set;}
    public Account account {get;set;}

    public PrintableAccountStrategy(ApexPages.StandardController stdController)
    {
        /*accountStrategyId= ApexPages.currentPage().getParameters().get('id');
        if(accountStrategyId!='' && accountStrategyId!=null){
           accStr = [Select id, name,Campo_de_Texto__c FROM Mi_Objeto__c WHERE Id=:accountStrategyId];
        }
        else
        {
            accStr=new Mi_Objeto__c();
        }*/
        
        List<String> fields = new List<String>();
        fields.add('Campo_de_Texto__c');
        fields.add('Account__c');
        if (!Test.isRunningTest())
        {
            stdController.addFields(fields);
        }
        
        this.accStr=(Mi_Objeto__c)stdController.getRecord(); 
        this.account=[select id,name from Account where id=:accStr.Account__c];

    }
    
    public String getGenerateTable()
    {
        return '<td>dinamically generated</td>';
    }
    
    @isTest
    private static void PrintableAccountStrategyTest() {
        // create test data
        Account testAccount = new Account(name = 'test');
        insert testAccount;
        Contact contact = new Contact(lastName = 'test', accountId = testAccount.id);
        insert contact;

        Mi_Objeto__c objeto = new Mi_Objeto__c();
        objeto.Campo_de_Texto__c='Esto es un texto';
        objeto.Account__c=testAccount.id;
        objeto.Contacto__c=contact.id;
        insert objeto;

        // requery all fields you require in your extension before 
        // instantiating the controller
        //testAccount = [select name, (select lastName from Contacts) from Account where id = :testAccount.id];
        objeto=[select Mi_Objeto__c.name,Mi_Objeto__c.Campo_de_Texto__c, Mi_Objeto__c.Account__c from Mi_Objeto__c where id=:objeto.id];
        ApexPages.StandardController controller = new APexPages.StandardController(objeto);
        PrintableAccountStrategy extension = new PrintableAccountStrategy(controller);
    }
}